var str = 'aabaabbbbbcccccccddd';

var i = 0,
    j = 1;
var maxRepeat = 0;
var maxRepeatStr = "";

while (i < str.length) {
    if (str[i] != str[j]) {
        console.log(i + "与" + j + "之间的字符相同!!都是字母" + str[i] + "他重复了" + (j - i) + "次");

        if (j - i > maxRepeat) {
            maxRepeat = (j - i);
            // maxRepeatStr = str.slice(i, j);
            maxRepeatStr = str[i];
        }
        i = j;
    }
    j++;
}

console.log("最大连续重复字符串为：" + maxRepeatStr);